@extends('admin.public')

@section('content')
    <div class="col-md-12">
        <section class="panel panel-default text-sm doc-buttons">
            <div class="panel-body">
                <a href="{{ route('admin.sort.sort_add',$chunk->id) }}" class="btn btn-info"><i
                            class="icon-plus ico"></i>
                    &nbsp; 添加分类</a>
                <button id="nestable-menu" class="btn btn-success" data-toggle="button">
                    <i class="fa fa-plus text fa-fw"></i>
                    <span class="text">收起</span>
                    <i class="fa fa-minus text-active fa-fw"></i>
                    <span class="text-active">展开</span>
                </button>
            </div>
        </section>
    </div>

    <div class="col-md-12">
        <div class="dd" id="nestable3">
            <ol class="dd-list">
                @if(!empty($sorts))
                    @foreach($sorts as $sortlv1)
                        <li class="dd-item dd3-item" data-id="13">
                            <div class="dd-handle dd3-handle">Drag</div>
                            <div class="dd3-content">
                                <a class="text-info"
                                   target="_blank"
                                   href="{{ route('sort',[$chunk['path'],$sortlv1['id']]) }}">{{ $sortlv1['name'] }}</a>
                                @if(empty($sortlv1['children']))
                                    <a href="{{ route('admin.sort.sort',$chunk->id) }}?del={{ $sortlv1['id'] }}"
                                       class="btn btn-xs btn-danger pull-right m-l">删除</a>
                                @endif
                                <a href="{{ route('admin.sort.sort_edit',[$chunk->id,$sortlv1['id']]) }}"
                                   class="btn btn-xs btn-default pull-right m-l">编辑</a>
                                <a href="{{ route('admin.info.info_add',[$chunk->id,$sortlv1['id']]) }}"
                                   class="btn btn-xs btn-default pull-right">添加信息</a>
                            </div>
                            <ol class="dd-list">
                                @if(!empty($sortlv1['children']))
                                    @foreach($sortlv1['children'] as $sortlv2)
                                        <li class="dd-item dd3-item" data-id="13">
                                            <div class="dd3-content">
                                                <a class="text-info"
                                                   target="_blank"
                                                   href="{{ route('sort',[$chunk['path'],$sortlv2['id']]) }}">{{ $sortlv2['name'] }}</a>
                                                @if(empty($sortlv2['children']))
                                                    <a href="{{ route('admin.sort.sort',$chunk->id) }}?del={{ $sortlv2['id'] }}"
                                                       class="btn btn-xs btn-danger pull-right m-l">删除</a>
                                                @endif
                                                <a href="{{ route('admin.sort.sort_edit',[$chunk->id,$sortlv2['id']]) }}"
                                                   class="btn btn-xs btn-default pull-right m-l">编辑</a>
                                                <a href="{{ route('admin.info.info_add',[$chunk->id,$sortlv2['id']]) }}"
                                                   class="btn btn-xs btn-default pull-right">添加信息</a>
                                            </div>
                                            <ol class="dd-list">
                                                @if(!empty($sortlv2['children']))
                                                    @foreach($sortlv2['children'] as $sortlv3)
                                                        <li class="dd-item dd3-item" data-id="13">
                                                            <div class="dd3-content">
                                                                <a class="text-info"
                                                                   target="_blank"
                                                                   href="{{ route('sort',[$chunk['path'],$sortlv3['id']]) }}">{{ $sortlv3['name'] }}</a>
                                                                @if(empty($sortlv3['children']))
                                                                    <a href="{{ route('admin.sort.sort',$chunk->id) }}?del={{ $sortlv3['id'] }}"
                                                                       class="btn btn-xs btn-danger pull-right m-l">删除</a>
                                                                @endif
                                                                <a href="{{ route('admin.sort.sort_edit',[$chunk->id,$sortlv3['id']]) }}"
                                                                   class="btn btn-xs btn-default pull-right m-l">编辑</a>
                                                                <a href="{{ route('admin.info.info_add',[$chunk->id,$sortlv3['id']]) }}"
                                                                   class="btn btn-xs btn-default pull-right">添加信息</a>
                                                            </div>
                                                            <ol class="dd-list">
                                                                @if(!empty($sortlv3['children']))
                                                                    @foreach($sortlv3['children'] as $sortlv4)
                                                                        <li class="dd-item dd3-item" data-id="13">
                                                                            <div class="dd3-content">
                                                                                <a class="text-info"
                                                                                   target="_blank"
                                                                                   href="{{ route('sort',[$chunk['path'],$sortlv4['id']]) }}">{{ $sortlv4['name'] }}</a>
                                                                                @if(empty($sortlv4['children']))
                                                                                    <a href="{{ route('admin.sort.sort',$chunk->id) }}?del={{ $sortlv4['id'] }}"
                                                                                       class="btn btn-xs btn-danger pull-right m-l">删除</a>
                                                                                @endif
                                                                                <a href="{{ route('admin.sort.sort_edit',[$chunk->id,$sortlv4['id']]) }}"
                                                                                   class="btn btn-xs btn-default pull-right m-l">编辑</a>
                                                                                <a href="{{ route('admin.info.info_add',[$chunk->id,$sortlv4['id']]) }}"
                                                                                   class="btn btn-xs btn-default pull-right">添加信息</a>
                                                                            </div>
                                                                            <ol class="dd-list">
                                                                                @if(!empty($sortlv4['children']))
                                                                                    @foreach($sortlv4['children'] as $sortlv5)
                                                                                        <li class="dd-item dd3-item"
                                                                                            data-id="13">
                                                                                            <div class="dd3-content">
                                                                                                <a class="text-info"
                                                                                                   target="_blank"
                                                                                                   href="{{ route('sort',[$chunk['path'],$sortlv5['id']]) }}">{{ $sortlv5['name'] }}</a>
                                                                                                @if(empty($sortlv5['children']))
                                                                                                    <a href="{{ route('admin.sort.sort',$chunk->id) }}?del={{ $sortlv5['id'] }}"
                                                                                                       class="btn btn-xs btn-danger pull-right m-l">删除</a>
                                                                                                @endif
                                                                                                <a href="{{ route('admin.sort.sort_edit',[$chunk->id,$sortlv5['id']]) }}"
                                                                                                   class="btn btn-xs btn-default pull-right m-l">编辑</a>
                                                                                                <a href="{{ route('admin.info.info_add',[$chunk->id,$sortlv5['id']]) }}"
                                                                                                   class="btn btn-xs btn-default pull-right">添加信息</a>
                                                                                            </div>
                                                                                        </li>
                                                                                    @endforeach
                                                                                @endif
                                                                            </ol>
                                                                        </li>
                                                                    @endforeach
                                                                @endif
                                                            </ol>
                                                        </li>
                                                    @endforeach
                                                @endif
                                            </ol>
                                        </li>
                                    @endforeach
                                @endif
                            </ol>
                        </li>
                    @endforeach
                @endif
            </ol>
        </div>
    </div>
@endsection

@section('css')
    <link rel="stylesheet" href="/public/theme/js/nestable/nestable.css" type="text/css"/>
@endsection

@section('js')
    <script src="/public/theme/js/sortable/jquery.sortable.js"></script>
    <script src="/public/theme/js/nestable/jquery.nestable.js"></script>
    <script src="/public/theme/js/nestable/demo.js"></script>
    <script>
        $(function () {
            $('#nestable-menu').click();
        })
    </script>
@endsection